package com.polaris.live.im.sfs.processor.impl

import com.polaris.live.im.sfs.COMMAND_STATE_CHANGE
import com.polaris.live.im.sfs.core.bean.DataArgument
import com.polaris.live.im.sfs.processor.AbstractMessageProcessor
import com.polaris.live.im.utils.AdminMessageUtil
import com.polaris.live.manager.UserStateManager

/**
 * 用户状态改变通知
 *
 * @author Created by lucas on 2023/10/19 16:33
 * @since 1.0.0
 */
class StateChangeMessageProcessor : AbstractMessageProcessor() {

    override fun shouldProcess(type: Int, command: String): Boolean {
        return command == COMMAND_STATE_CHANGE
    }

    override suspend fun handle(type: Int, command: String, argument: DataArgument) {
        val sfsObject = argument.getSfsData() ?: return

        UserStateManager.eventDispatch(AdminMessageUtil.parseNoticeMessage(sfsObject))
    }

}